home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!oxas.demon.co.uk
- From: "Michael R. Mayer" <mmayer@oxas.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Re: Translate C++ to C
- Date: Thu, 04 Jan 1996 23:25:26 +0100
- Organization: None now!
- Message-ID: <103996057wnr@oxas.demon.co.uk>
- References: <4ce768$5iu@news.uit.no>
- Reply-To: mmayer@oxas.demon.co.uk
- X-NNTP-Posting-Host: oxas.demon.co.uk
- X-Newsreader: Newswin Alpha 0.9
- X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!oxas.demon.co.uk
-
- Oh, good another student...
-
- Rather than just throw rocks here are a few pointers...
-
-
-
- In article: <4ce768$5iu@news.uit.no> odu@stud.cs.uit.no (O.O) writes:
- >
- > Could C/C++ gurus translate the following C++ to C.
- >
- > 1) Comp ->set(Ts :: execute, flow ->GetId(),
- > Ts :: abs, x);
-
- -> (the arrow operator) is used to access members when you only have a
- pointer to an instance. Thus Comp is presumably a pointer to an
- instance (class unknown). Thus in 1 the method (member function)
- set() is being called (N.B. there may be more than one set() method)
-
- :: In the case of 1 this is probably the class scope resolution
- operator. I would GUESS that execute & abs are methods of the
- class Ts.
-
- >
- > 2) Ts *kflow = new Ts(2);
- >
-
- The new operator is like malloc() only MUCH better since there is no
- need to do casting and it is more flexible due to constructors for
- starters. The new operator creates an new instance of a class. It
- returns a pointer to the instance. As part of the process it calls the
- class constructor. In this case the constructor is being passed an
- argument '2'.
-
- I suggest that you try reading at least one C++ primer before you try to
- understand what this code is doing. Please do some work in future before
- asking others.
-
- --
- Michael
-
- (load '/users/mmayer/standard_disclaimer.lsp)
- ------------------------------------------------------
- " 'cause we don't know where we come from.
- We don't know what we are."
-
-